package com.imooc.collection;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by JiaJia on 2019/5/31 0031.
 */
public class TestGeneric {
    public List<Course> courses;

    public TestGeneric(){
        this.courses=new ArrayList<Course>();
    }
    public void testAdd(){
        Course cr1=new Course("1","大学语文");
        courses.add(cr1);
        Course cr2=new Course("2","Java基础");
        courses.add(cr2);
    }
    public void testForEach(){
        for (Course cr:courses) {
            System.out.println(cr.id+":"+cr.name);
        }
    }

    public static void main(String[] args) {
        TestGeneric tg=new TestGeneric();
        tg.testAdd();
        tg.testForEach();
    }
}